package main

import "fmt"

func main() {
	var grade string = "8"
	var marks int = 50

	switch marks {
		case 90: grade = "A"
		case 80: grade = "B"
		case 50, 60, 70: grade = "C"
		default: grade = "D"
	}

	switch {
		case grade == "A":
			fmt.Printf("优秀！\n")
		case grade == "B", grade == "C":
			fmt.Printf("良好\n")
		case grade == "D":
			fmt.Printf("及格\n")
		case grade == "F":
			fmt.Printf("不及格\n")
		default:
			fmt.Printf("差\n")
	}
	fmt.Printf("您的等级是：%s\n", grade)

	var x interface {}
	switch i := x.(type) {
		case nil:
			fmt.Printf("x 的类型是：%T", i)
		case int:
			fmt.Printf("x 的类型是：int")
		case float64:
			fmt.Printf("x 的类型是：float64")
		case func(int) float64:
			fmt.Printf("x 是 func(int) 型")
		case bool, string:
			fmt.Printf("x 的类型是：bool 或 string 型\n")
	}

	switch {
		case false:
			fmt.Println("1. case条件语句为false")
			fallthrough
		case true:
			fmt.Println("2. case条件语句为true")
			fallthrough
		case false:
			fmt.Println("3. case条件语句为false")
			fallthroug
		case true:
			fmt.Println("4. case条件语句为true")
		case false:
			fmt.Println("5. case条件语句为false")
			fallthrough
		default:
			fmt.Println("6. 默认case")
	}
}